package com.cloud.pole.recharge.controller;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import lombok.extern.slf4j.Slf4j;

/*
*2019年4月30日
*cloud-weixin
*author:frank-chen
*/
@Controller
@RequestMapping("recharge/synNotify")
@Slf4j
public class SynNotifyController {

	/**
	 * 4.9支付结果异步通知
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@ResponseBody
    @RequestMapping(value = "/resultNotify")
	public void ResultNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
		try {
			// 读取参数
			InputStream inputStream;
			StringBuffer sb = new StringBuffer();
			inputStream = request.getInputStream();
			String s;
			BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
			while ((s = in.readLine()) != null) {
				sb.append(s);
			}
			in.close();
			inputStream.close();
			log.info("获取状态返回：" + sb.toString());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
